/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef LIB2D_OBJECTS_IMAGESIMPLEREP_H
#define LIB2D_OBJECTS_IMAGESIMPLEREP_H

#include <AutoPtr.h>
#include <SharedRep.h>
#include <HardwareDependentObject.h>
#include <filesystem/String.hpp>
#include <pictureformat/Loader.h>
#include <lib2d/hard/Image.h>
#include <lib2d/hard/Manager.h>

namespace liba
{
namespace lib2d
{
namespace objects
{

class ImageSimpleRep :
	public HardwareDependentObject<hard::Manager, hard::Image>,
	public SharedPrecachedRepBase
{
	AutoPtr< pictureformat::Loader > pl;
public:
	explicit ImageSimpleRep( const filesystem::String & image_name )
	{
		hard::Manager::add_dependent( this );
	}
	~ImageSimpleRep()
	{
		hard::Manager::remove_dependent( this );
	}
	void load( const filesystem::String & image_name );
	virtual void on_add_hardware(hard::Manager::hardware_type * ha);
	hard::Image * get_image( /*const*/ hard::Renderer * rend )
	{
		return find_data( rend );
	}
};

} //namespace objects
} //namespace lib2d
} //namespace liba

using namespace liba;

#endif //LIB2D_OBJECTS_IMAGESIMPLEREP_H

